]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
autorun: simplify code
authorCosimo Cecchi <cosimoc@gnome.org>
Tue, 19 Jun 2012 19:17:07 +0000 (15:17 -0400)
committerCosimo Cecchi <cosimoc@gnome.org>
Wed, 20 Jun 2012 14:15:22 +0000 (10:15 -0400)
Split autorun conditions into separate logic blocks instead of a single
huge if.

https://bugzilla.gnome.org/show_bug.cgi?id=660595

js/ui/autorunManager.js

index 9d39690e98488b0b7b2ff7a800e450bfcdecdf45..7283e16cd2d8aafc8e296af95bbfec01303a640d 100644 (file)
@@ -23,12 +23,14 @@ const AutorunSetting = {
 };
 
 // misc utils
-function ignoreAutorunForMount(mount) {
+function shouldAutorunMount(mount) {
     let root = mount.get_root();
     let volume = mount.get_volume();
 
-    if ((root.is_native() && !isMountRootHidden(root)) &&
-        (volume && volume.allowAutorun && volume.should_automount()))
+    if (!volume || !volume.should_automount() || !volume.allowAutorun)
+        return false;
+
+    if (!root.is_native() || isMountRootHidden(root))
         return false;
 
     return true;
@@ -270,7 +272,7 @@ const AutorunResidentSource = new Lang.Class({
     },
 
     addMount: function(mount, apps) {
-        if (ignoreAutorunForMount(mount))
+        if (!shouldAutorunMount(mount))
             return;
 
         let filtered = this._mounts.filter(function (element) {
@@ -448,7 +450,7 @@ const AutorunTransientDispatcher = new Lang.Class({
             return;
 
         // if the mount doesn't want to be autorun, return
-        if (ignoreAutorunForMount(mount))
+        if (!shouldAutorunMount(mount))
             return;
 
         let setting = this._getAutorunSettingForType(contentTypes[0]);